package com.xiaocg.juc.future;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

public class FutureTaskDemo {
    public static void main(String[] args)throws Exception {
        FutureTask<String> future = new FutureTask<>(new MyCallable());
        new Thread(future).start();
        String o = future.get();
        System.out.println(o);

    }
}

class MyCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        TimeUnit.SECONDS.sleep(3);
        System.out.println("ddd::"+Thread.currentThread().getName());
        return "hello future";
    }
}
